package top.zy.service.zymallgoodsservice.category.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import top.zy.service.zymallgoodsinterface.entity.Category;
import top.zy.service.zymallgoodsservice.category.service.CategoryService;

import java.util.List;

/**
 * @Author: HouZeYu
 * @Description:
 * @Date: Created in 15:18 2019/6/19
 */
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    @Qualifier("categoryServiceImpl")
    private CategoryService categoryService;

    /***
     * 根据父节点id查询商品分类
     * @param pid
     * @return
     */
    @GetMapping("/list")
    public List<Category> queryCategoryListByPid(@RequestParam("pid") Long pid){

        List<Category> categoryList=categoryService.queryCategoryListByPid(pid);
        return categoryList;
    }
    /***
     *根据品牌id查询商品分类
     * @param brandId
     * @return
     */
    @GetMapping("/bid/{brandId}")
    public List<Category> queryCategoryListByBrandId(@PathVariable("brandId") Long brandId){
      return categoryService.queryCategoryListByBrandId(brandId);
    }

    /***
     * 根据分类id查询商品分类
     * @param ids
     * @return
     */
    @GetMapping("/list/ids")
    public List<Category> queryCategoryListByIds(@RequestParam("ids") List<Long> ids){
     return categoryService.queryCategoryListByIds(ids);
    }
}
